package org.musicPlayerServer.gui;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

public class GuiManager {

    String head,tail;
    static GuiManager soleInstance = new GuiManager();

    private GuiManager() {
    }

    public static GuiManager getInstance() {
	return soleInstance;
    }
    
    public void init() throws IOException{
	head = readFileAsString("web/head.txt"); 
	tail = readFileAsString("web/tail.txt"); 
    }
    
    public String getHead(){
	return head;
    }
    public String getTail(){
	return tail;
    }
    
    private static String readFileAsString(String filePath)
    throws java.io.IOException{
        StringBuffer fileData = new StringBuffer(1000);
        BufferedReader reader = new BufferedReader(
                new FileReader(filePath));
        char[] buf = new char[1024];
        int numRead=0;
        while((numRead=reader.read(buf)) != -1){
            String readData = String.valueOf(buf, 0, numRead);
            fileData.append(readData);
            buf = new char[1024];
        }
        reader.close();
        return fileData.toString();
    }

}
